﻿// CTabPage1Dialog.cpp: 实现文件
//

#include "pch.h"
#include "DataSynApp.h"
#include "afxdialogex.h"
#include "CTabPage1Dialog.h"
#include "DataSynAppDlg.h"

// CTabPage1Dialog 对话框

IMPLEMENT_DYNAMIC(CTabPage1Dialog, CDialogEx)

CTabPage1Dialog::CTabPage1Dialog(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_TABPAGE1, pParent)
{

}

CTabPage1Dialog::~CTabPage1Dialog()
{
}

void CTabPage1Dialog::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_STATIC_pic, m_pictureCtrl);
	DDX_Control(pDX, IDC_RADIO1, m_radio1);
	DDX_Control(pDX, IDC_RADIO2, m_radio2);
}


BEGIN_MESSAGE_MAP(CTabPage1Dialog, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CTabPage1Dialog::OnBnClickedButton1)
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_BUTTON6, &CTabPage1Dialog::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON2, &CTabPage1Dialog::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON7, &CTabPage1Dialog::OnBnClickedButton7)
END_MESSAGE_MAP()


// CTabPage1Dialog 消息处理程序


void CTabPage1Dialog::OnBnClickedButton1()
{
	ShellExecute(NULL, _T("open"), _T("http://114.251.197.140:8080"), NULL, NULL, SW_SHOWNORMAL);
}


BOOL CTabPage1Dialog::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	ModifyStyle(WS_THICKFRAME, 0);
	HBITMAP hBitmap = (HBITMAP)LoadImage(AfxGetInstanceHandle(),
		"./res/ww.bmp", // 图片路径，相对或绝对
		IMAGE_BITMAP,
		0, 0, // 使用实际大小
		LR_CREATEDIBSECTION | LR_LOADFROMFILE);
	if (hBitmap != NULL)
	{
		// 设置图片到Picture Control
		m_pictureCtrl.SetBitmap(hBitmap);
	}
	else
	{
		// 处理加载失败的情况
		AfxMessageBox(_T("Failed to load bitmap."));
	}

	//iniData
	CString SendType = iniData[_T("SendData")][_T("SendType")];

	if (SendType == "0")
	{
		m_radio2.SetCheck(true); 
	}
	else
	{
		m_radio1.SetCheck(TRUE); 
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}


void CTabPage1Dialog::OnPaint()
{
	CPaintDC dc(this); // 设备上下文用于绘制

}


void CTabPage1Dialog::OnBnClickedButton6()
{
	ShellExecute(NULL, _T("open"), _T("http://10.76.204.106:8080"), NULL, NULL, SW_SHOWNORMAL);
}


void CTabPage1Dialog::OnBnClickedButton2()
{
	bool r1 = m_radio1.GetCheck();
	if (r1){
		iniData[_T("SendData")][_T("SendType")] = "1";
	}
	else {
		iniData[_T("SendData")][_T("SendType")] = "0";
	}
	WriteIniFile(appDlg->exePath, iniData);
	AfxMessageBox(_T("保存成功。"), MB_OK | MB_ICONINFORMATION, 0);

}


void CTabPage1Dialog::OnBnClickedButton7()
{
	//OnOK();
}
